package com.yes.yll;

import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;

import java.lang.reflect.Method;

public class AppYanLulu {
    public static void main(String[] args) throws Exception{
        //String s = RandomStringUtils.randomAlphabetic(6);
        //System.out.println(s);

        //创建User类的实例
        //面向对象的思想
        /*User u = new User();
        u.setName("lili");
        System.out.println(u.getName());
        u.setAge(12);
        System.out.println(u.getAge());*/

        //通过类的完整限定名加载某个类对象；完整限定名=包名加类名
        Class<?> uu = Class.forName("com.yes.yll.User");
        //uu 相当User类
        Object o = uu.newInstance();

        Method setName = uu.getMethod("setName", String.class);
        setName.invoke(o,"cuize");
        Method getName = uu.getMethod("getName");
        Object result = getName.invoke(o);
        System.out.println(result);

        Method setAge = uu.getMethod("setAge", Integer.class);
        setAge.invoke(o,100);
        Method getAge = uu.getMethod("getAge");
        Object age = getAge.invoke(o);
        System.out.println(age);


    }
}


